package com.syher.seconds.kill.provider.starter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.function.Function;

@EnableAutoConfiguration
@ComponentScan(basePackages = {
        "com.syher.seconds.kill.provider.core.configure",
        "com.syher.seconds.kill.provider.service.impl"
})
public class SecondsKillProviderStarter implements CommandLineRunner {

    @Autowired
    RedisTemplate<String, String> redisTemplate;

    public static void main(String[] args) {
        SpringApplication.run(SecondsKillProviderStarter.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        redisTemplate.keys("stock*").forEach(s -> redisTemplate.delete(s));
    }
}
